// 尝试
// const axios = require("axios");
// axios.get("https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json",{
// 	params:{
// 		ct:"上海",
// 		ci:10,
// 		channelId:4
// 	}
// }).then(value=>{
// 	console.log(value.data.data.hot);
// })


const express = require("express");
const axios = require("axios");
const app = express();
app.use(express.static(__dirname));
// app.use(function(req,res,next){
// 	res.set("Access-Control-Allow-Origin","*");
// 	next();
// })
app.get("/movieList",function(req,res){
	axios.get("https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json", {
		params: {
			ct: "上海",
			ci: 10,
			channelId: 4
		}
	}).then(value => {
		// console.log(value.data.data.hot);
		res.json(value.data.data);
	})
})
app.get("/movieListJsonp",function(req,res){
	const cb = req.query.cb  || "my";
	axios.get("https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json", {
		params: {
			ct: "上海",
			ci: 10,
			channelId: 4
		}
	}).then(value => {
		// console.log(value.data.data.hot);
		// res.json(value.data.data);
		res.send(cb+"("+JSON.stringify(value.data.data)+")")
	})
})
app.listen(8090,function(){
	console.log("success");
})